package LocalCRM;

$VERSION = 1;

use Config::IniFiles;
use Encode;

require 'propis.pl';

sub new
{
    my $class = shift;
    my $self = {};

    $self->{_cfg} = Config::IniFiles->new(-file=>'/var/www/region.ftn.org.ru/public_html/crm/core/settings.ini');

    bless $self, $class;
    return $self;
}

sub nds
{
    my $self = shift;

    return
    {
	'percent'=> $self->{_cfg}->val('Common','Nalog'),
	'ratio'	 => 1/100*$self->{_cfg}->val('Common','Nalog'),
	'value'  => $self->amount( $_[0]/100*$self->{_cfg}->val('Common','Nalog') ),
	'without'=> $self->amount( $_[0]-($_[0]/100*$self->{_cfg}->val('Common','Nalog')) ),
    };
}

sub amount	{ return sprintf '%0.2f', $_[1]; }
sub num2str	{ return propis::post(shift->amount($_[0])); }
sub utf2win	{ return encode('windows-1251',decode_utf8($_[1])); }
